home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 35 / Amiga Format AFCD35 (Issue 119, Jan 1999).iso / -in_the_mag- / reader_requests / fredobbutils / bbsrc / bootfade.s < prev    next >
Text File  |  1998-11-06  |  5KB  |  283 lines

  1. ************* Bootblock spécial *****************
  2. * - affiche un gfx au format RAW (cf.GFXCONV)    *
  3. * - attend un clic de souris            *
  4. **************** Par Frédo!! ********************
  5.  
  6. * Another bootblock example:
  7. * with a color fading routine
  8.  
  9.     incdir    ASM:/Include/
  10.     include    equ.s
  11.     include    exec/types.i
  12.     include    graphics/text.i
  13.     include    graphics/gfx.i
  14.     include    graphics/rastport.i
  15.  
  16.     rsreset
  17. planes    rs.l    1
  18. gfxbase    rs.l    1
  19. coplistptr rs.l    1
  20. olddma    rs.w    1
  21. scrw    rs.w    1
  22. scrh    rs.w    1
  23. rast    rs.b    rp_SIZEOF
  24. bmap    rs.b    bm_SIZEOF
  25. VARSIZE    rs.w    0
  26.  
  27. WIDTH=320*1
  28. HEIGHT=256
  29. DEPTH=1
  30. BYTESPERROW=WIDTH/8
  31. PLSIZE=(BYTESPERROW)*HEIGHT
  32. PLANESIZE=PLSIZE*DEPTH
  33.  
  34. COL0=$789
  35. COL1=$f14
  36.  
  37. ;coordonnées dessin
  38. X=100
  39. Y=50
  40.  
  41. ;DBUG=0
  42.  
  43. Start:
  44.     IFND    DBUG
  45.     dc.b    "DOS",1
  46.     dc.l    0,$370
  47.     ENDC
  48. Main:
  49.     movem.l    d0-a6,-(sp)
  50.     lea    -VARSIZE(sp),sp    ;on utilise la pile comme base des variables
  51.     move.l    sp,a5        ;VarBase en a5
  52.  
  53.     IFD    DBUG
  54.     move.l    4.w,a6
  55.     ENDC
  56.     move.l    $9c(a6),gfxbase(a5)
  57. * Allouer buffer pour les bitplanes & copperlist
  58.     move.l    #BUFSIZE,d0
  59.     move.l    #$10002,d1
  60.     jsr    AllocMem(a6)
  61.     move.l    d0,planes(a5)
  62.     beq.w    fin
  63.     move.l    d0,d4
  64.  
  65.     lea    rast(a5),a1
  66.     move.l    a1,-(sp)
  67.     move.l    gfxbase(a5),a6
  68.     jsr    InitRastPort(a6)
  69.  
  70.     lea    bmap(a5),a0
  71.     move.l    a0,-(sp)
  72. * adresse des bitplanes
  73. ;    lea    bm_Planes(a0),a0
  74.     addq.l    #8,a0
  75.     moveq    #DEPTH-1,d0
  76. .pl    move.l    d4,(a0)+
  77.     add    #PLSIZE,d4
  78.     dbf    d0,.pl
  79.     move.l    (sp)+,a0
  80.     move.l    (sp)+,a1
  81.     move.l    a0,rp_BitMap(a1)
  82.     moveq    #DEPTH,d0
  83.     move    #WIDTH,d1
  84.     move    #HEIGHT,d2
  85.     movem    d1-d2,scrw(a5)
  86.     jsr    InitBitMap(a6)
  87. * copier les données RAW vers bitplane
  88.     lea    rawdata(pc),a0
  89.     move.l    planes(a5),a2    ;adr bitplane
  90.     add    #(Y*BYTESPERROW)+(X/8),a2
  91.     moveq    #6-1,d7    ;nbre de lignes
  92. .cop0
  93.     move.l    a2,a1
  94.     moveq    #(RAWSIZE/6)-1,d0    ;octets/ligne = rawsize/#lignes
  95. .cop    move.b    (a0)+,(a1)+
  96.     dbf    d0,.cop
  97.     add    #BYTESPERROW,a2        ;ligne suivante
  98.     dbf    d7,.cop0
  99.  
  100.     lea    $dff000,a4
  101.     move    $02(a4),olddma(a5)
  102.     or    #$8000,olddma(a5)
  103.     move    #$7fff,$96(a4)    ;dma off
  104.     lea    coplist(pc),a1
  105. * adresse des bitplanes
  106.     move.l    planes(a5),d0
  107.     move.l    d0,a2
  108.     move    d0,lo1-coplist(a1)
  109.     swap    d0
  110.     move    d0,hi1-coplist(a1)
  111. * copier copperlist ds buffer
  112.     add    #PLSIZE,a2
  113.     move.l    a2,a3
  114.     moveq    #(COPSIZE/4)-1,d0
  115. .copy
  116.     move.l    (a1)+,(a2)+
  117.     dbf    d0,.copy
  118.  
  119.     move.l    a3,$80(a4)
  120.     move.l    a3,coplistptr(a5)
  121.     clr    $88(a4)
  122.     move    #%1000011111000000,$96(a4)    ;mon dma
  123.  
  124. .w    btst    #6,$bfe001
  125.     bne.s    .w
  126.  
  127.     bsr.b    fade
  128.  
  129. closeall
  130.     move.l    planes(a5),a1
  131.     move.l    #BUFSIZE,d0
  132.     move.l    4.w,a6
  133.     jsr    FreeMem(a6)
  134. restore
  135.     move.l    $9c(a6),a0
  136.     move.l    38(a0),$80(a4)
  137.     clr    $88(a4)
  138.     move    olddma(a5),$96(a4)
  139. fin
  140.     lea    VARSIZE(sp),sp    ;restitue la pile
  141.     movem.l    (sp)+,d0-a6
  142.  
  143. init
  144.     IFND    DBUG
  145.     lea    expansion.name(pc),a1
  146.     moveq    #37,d0
  147.     jsr    -552(a6)
  148.     tst.l    d0
  149.     beq.b    .err
  150.     move.l    d0,a1
  151.     bset    #6,34(a1)
  152.     jsr    -414(a6)
  153. .err    lea    dos.name(pc),a1
  154.     jsr    -96(a6)
  155.     tst.l    d0
  156.     beq.b    .nodos
  157.     move.l    d0,a0
  158.     move.l    22(a0),a0
  159.     moveq    #0,d0
  160.     rts
  161. .nodos    moveq    #-1,d0
  162.     ENDC
  163.     rts
  164.  
  165.  
  166. ; routine de fading de couleurs
  167. fade:
  168.     lea    cpal(pc),a0
  169.     moveq    #2,d0
  170.  
  171.     moveq    #15,d5    ;compteur
  172. .debut
  173.     move.l    a0,a4
  174.     move.l    d0,d4
  175. .coul_suiv
  176.     tst    d0
  177.     beq.s    .prochain_tour
  178.     subq    #1,d0
  179.     move    (a0)+,d1
  180.     beq.s    .coul_suiv
  181. .fade_coul
  182.     move.b    d1,d3
  183.     and.b    #$0f,d3        ;composante bleue en d3
  184.     lsr    #4,d1
  185.     move.b    d1,d2
  186.     and.b    #$0f,d2        ;composante verte en d2
  187.     lsr    #4,d1
  188.     and    #$000f,d1    ;composante rouge en d1
  189. .rouge
  190.     tst.b    d1
  191.     beq.s    .vert
  192.     subq.b    #1,d1
  193. .vert
  194.     tst.b    d2
  195.     beq.s    .bleu
  196.     subq.b    #1,d2
  197. .bleu
  198.     tst.b    d3
  199.     beq.s    .save_coul
  200.     subq.b    #1,d3
  201. .save_coul
  202.     lsl    #8,d1
  203.     lsl    #4,d2
  204.     or    d2,d1
  205.     or.b    d3,d1
  206.     and    #$0fff,d1
  207.     move    d1,-2(a0)
  208.     bra.s    .coul_suiv
  209.  
  210. .prochain_tour
  211.     move.l    d4,d0
  212.     move.l    a4,a0
  213.  
  214. ; insérer ici les routines:
  215. ;  - d'actualisation de la palette. ex: LoadRGB4() etc...
  216. ;  - de delai (WaitVBL)
  217.     movem.l    d0-a6,-(sp)
  218.     move.l    gfxbase(a5),a6
  219.     moveq    #3,d7
  220. .waitvbl
  221.     jsr    WaitTOF(a6)
  222.     dbf    d7,.waitvbl
  223.     move.l    coplistptr(a5),a0
  224.     move    (a4),col0ptr-coplist(a0)
  225.     move    2(a4),col1ptr-coplist(a0)
  226.     movem.l    (sp)+,d0-a6
  227.  
  228.     dbf    d5,.debut
  229.  
  230. .fin
  231.     rts
  232.  
  233. *** DATA
  234. LORES=(DEPTH<<12)!$200
  235. HIRES=LORES!$8000
  236. LACE=4
  237.  
  238. RES=LORES
  239.  
  240. coplist:
  241.  DC.w $0100,RES
  242.  dc.w $0108,$0000
  243.  dc.w $008E,$2981
  244.  DC.w $0090,$29c1
  245.  IF RES=LORES
  246.  dc.w $0092,$0038
  247.  DC.w $0094,$00D0
  248.  ELSE
  249.  dc.w $0092,$003c
  250.  dc.w $0094,$00d4
  251.  ENDC
  252.  DC.w $0180
  253. col0ptr:
  254.  dc.w COL0
  255.  dc.w $0182
  256. col1ptr:
  257.  dc.w COL1
  258.  dc.w $00e0
  259. hi1:dc.w 0
  260.  dc.w $00e2
  261. lo1:dc.w 0
  262.  dc.w $FFFF,$FFFE    ;fin de la liste copper
  263. COPSIZE=*-coplist
  264. BUFSIZE=PLANESIZE+COPSIZE
  265.  
  266. cpal    dc COL0,COL1
  267.  
  268. dos.name    dc.b    'dos.library',0
  269. expansion.name    dc.b    'expansion.library',0
  270.  
  271. * RAW gfx data
  272. rawdata:
  273.  dc.b %01111111,%01111100,%01111110,%11111100,%01111110,%00011000
  274.  dc.b %11000000,%11000010,%11000000,%11000010,%11000011,%00111100
  275.  dc.b %11000000,%11000010,%11000000,%11000010,%11000011,%00111100
  276.  dc.b %11111100,%11111100,%11111100,%11000010,%11000011,%00011000
  277.  dc.b %11000000,%11000010,%11000000,%11000010,%11000011,%00000000
  278.  dc.b %11000000,%11000010,%01111110,%11111100,%01111110,%00011000
  279. RAWSIZE=*-rawdata
  280.  
  281. End:
  282.     dcb.b    512*2,0
  283.